/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

/**
 *
 * @author Ee Ting
 */
@Entity
public class SalesForecastRecord implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long forecastId;
    @OneToOne(cascade = {CascadeType.PERSIST})
    private Product prod;
    private int month;
    private int year;
    private int promotionInd;
    private int marketInd;
    private int previousYear;
    private int promotionSales;
    private int previousBase;
    private double yoyPercent;
    private int yoyFigure;
    private int baseProjection;
    private int promotionPredicted;
    private int promotionType;
    private int forecastFigure;
    @OneToOne(cascade = {CascadeType.PERSIST})
    private SystemUser createdBy;
    private Timestamp createdDate;
    
    //@OneToMany(cascade={CascadeType.PERSIST})
    //private List<SOPRecord> sopRecords = new ArrayList<SOPRecord>();
    
    public void create(Product pro, int mth, int yr, int pInd, int mInd, int pYr, int pSales, int pBase
            , double yPercent, int yFigure, int bProject, int promo, int promoType, int fFigure, SystemUser user)
    {
        this.setProd(pro);
        this.setMonth(mth);
        this.setYear(yr);
        this.setPromotionInd(pInd);
        this.setMarketInd(mInd);
        this.setPreviousYear(pYr);
        this.setPromotionSales(pSales);
        this.setPreviousBase(pBase);
        this.setYoyPercent(yPercent);
        this.setYoyFigure(yFigure);
        this.setBaseProjection(bProject);
        this.setPromotionPredicted(promo);
        this.setPromotionType(promoType);
        this.setForecastFigure(fFigure);
        this.setCreatedBy(user);
        java.util.Date tmp = new java.util.Date();
        this.setCreatedDate(new Timestamp(tmp.getTime()));
        //this.setSopRecords(null);
    }

    /*public List<SOPRecord> getSopRecords() {
        return sopRecords;
    }

    public void setSopRecords(List<SOPRecord> sopRecords) {
        this.sopRecords = sopRecords;
    }*/    
    
    public SystemUser getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(SystemUser createdBy) {
        this.createdBy = createdBy;
    }

    public Timestamp getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Timestamp createdDate) {
        this.createdDate = createdDate;
    }
    

    public int getBaseProjection() {
        return baseProjection;
    }

    public void setBaseProjection(int baseProjection) {
        this.baseProjection = baseProjection;
    }

    public int getForecastFigure() {
        return forecastFigure;
    }

    public void setForecastFigure(int forecastFigure) {
        this.forecastFigure = forecastFigure;
    }

    public int getMarketInd() {
        return marketInd;
    }

    public void setMarketInd(int marketInd) {
        this.marketInd = marketInd;
    }

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        this.month = month;
    }

    public int getPreviousBase() {
        return previousBase;
    }

    public void setPreviousBase(int previousBase) {
        this.previousBase = previousBase;
    }

    public int getPreviousYear() {
        return previousYear;
    }

    public void setPreviousYear(int previousYear) {
        this.previousYear = previousYear;
    }

    public Product getProd() {
        return prod;
    }

    public void setProd(Product prod) {
        this.prod = prod;
    }

    public int getPromotionPredicted() {
        return promotionPredicted;
    }

    public void setPromotionPredicted(int promotion) {
        this.promotionPredicted = promotion;
    }

    public int getPromotionInd() {
        return promotionInd;
    }

    public void setPromotionInd(int promotionInd) {
        this.promotionInd = promotionInd;
    }

    public int getPromotionSales() {
        return promotionSales;
    }

    public void setPromotionSales(int promotionSales) {
        this.promotionSales = promotionSales;
    }

    public int getPromotionType() {
        return promotionType;
    }

    public void setPromotionType(int promotionType) {
        this.promotionType = promotionType;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public int getYoyFigure() {
        return yoyFigure;
    }

    public void setYoyFigure(int yoyFigure) {
        this.yoyFigure = yoyFigure;
    }

    public double getYoyPercent() {
        return yoyPercent;
    }

    public void setYoyPercent(double yoyPercent) {
        this.yoyPercent = yoyPercent;
    }

    public Long getForecastId() {
        return forecastId;
    }

    public void setForecastId(Long Id) {
        this.forecastId = Id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (forecastId != null ? forecastId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SalesForecastRecord)) {
            return false;
        }
        SalesForecastRecord other = (SalesForecastRecord) object;
        if ((this.forecastId == null && other.forecastId != null) || (this.forecastId != null && !this.forecastId.equals(other.forecastId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.SalesForecastRecord[ id=" + forecastId + " ]";
    }
    
}
